package com.joinway.framework.admin.core.plugin.service;

import java.util.List;
import java.util.Map;

import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.joinway.framework.admin.bean.domain.PushLogHistory;
import com.joinway.framework.admin.core.bean.DataRecord;
import com.joinway.framework.admin.core.chart.constant.SqlClauseFactory;
import com.joinway.framework.admin.core.service.table.TableService;
import com.joinway.framework.bean.logging.annotation.InputLog;
import com.joinway.framework.data.jdbc.bean.QueryCriteria;
import com.joinway.framework.data.jdbc.bean.WhereClause;
import com.joinway.framework.data.jdbc.service.SqlService;

@Deprecated
//@Service
public class PushLogHistoryTableService extends TableService {

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	@InputLog
//	@OutputLog
	@Override
	public DataRecord find(String table, String query, Integer page, Integer rows, Map args) throws Exception {
		QueryCriteria criteria = super.buildQueryCriteria(table, query, page, rows);
		
		String where = "";
		String order = "";
		List<String> params;
		if(criteria != null){
			WhereClause wc = SqlService.parseWhere(criteria);
			order = SqlService.parseOrder(criteria);
		}

	
		String sql = SqlClauseFactory.createPushLogHistoryQuery() + where + order;
		
		List<PushLogHistory> histories = repository.find(PushLogHistory.class, sql);
		
		List<?> records = repository.find("select count(*) total from ($selectClause) his $where");
			
//		new DataRecord(domains:histories, count:count.total);
//		[histories, count.total]
		return null;
	}
}

